package org.galaxyworld.flycode.dbspy;

import org.galaxyworld.flycode.config.AppConfig;
import org.galaxyworld.flycode.core.Task;
import org.galaxyworld.flycode.model.Table;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class ModelTask implements Task {

    @Resource
    private MySQLSpy mySQLSpy;

    @Override
    public void exec() {
        List<Table> tables = mySQLSpy.getTables(AppConfig.getSchema());
        tables.forEach((table) -> {
            ModelFileGenerator generator = new ModelFileGenerator(table);
            generator.generate();
        });
    }
}
